package com.msmall.community.admin.action;

import com.msmall.base.action.HTMLBaseAction;
import com.msmall.base.util.ConstantDB;
import com.msmall.community.common.model.ScoreRule;
import com.msmall.community.common.service.ScoreRuleManager;

public class ScoreRuleAction extends HTMLBaseAction {

	private static final long serialVersionUID = 3678896540540539186L;

	private Long scoreRuleId;
	
	private ScoreRule scoreRule;
	
	private ScoreRuleManager scoreRuleManager;
	
	public String execute(){
		page.setClazz(ScoreRule.class);
		page.setOrderBy("scoreRuleId");
		page.setOrder("asc");
		page.setPageSize(10);
		scoreRuleManager.getPagination(page);
		return SUCCESS;
	}

	public String create(){
		scoreRule = null;
		return SUCCESS;
	}
	
	public String update(){
		scoreRule = (ScoreRule) scoreRuleManager.get(ScoreRule.class, scoreRuleId);
		return SUCCESS;
	}
	public String save(){
		if(scoreRule.getEnabled() == null){
			scoreRule.setEnabled(ConstantDB.UNAVALIABLE);
		}
		scoreRuleManager.saveScoreRule(scoreRule);
		return execute();
	}

	public Long getScoreRuleId() {
		return scoreRuleId;
	}

	public void setScoreRuleId(Long scoreRuleId) {
		this.scoreRuleId = scoreRuleId;
	}

	public ScoreRule getScoreRule() {
		return scoreRule;
	}

	public void setScoreRule(ScoreRule scoreRule) {
		this.scoreRule = scoreRule;
	}

	public ScoreRuleManager getScoreRuleManager() {
		return scoreRuleManager;
	}

	public void setScoreRuleManager(ScoreRuleManager scoreRuleManager) {
		this.scoreRuleManager = scoreRuleManager;
	}

}
